#include "mythread.h"

QSemaphore freespace(buffersize);
QSemaphore usespace(0);
produce::produce(QObject *parent) : QThread(parent)
{

}
void produce::run()
{
    for(int i=0;i<datasize;i++)
    {
        freespace.acquire();
        std::cerr<<i<<":produce-->";
        usespace.release();
    }
}
consumer::consumer(QObject *parent): QThread(parent)
{


}
void consumer::run()
{
    for(int i=0;i<datasize;i++)
    {
        usespace.acquire();
        std::cerr<<i<<":consumer-->\n";
        freespace.release();
    }
}
